package org.chaiyi.template.core.common.contract.method;

import org.chaiyi.template.core.common.contract.Contractor;
import reactor.core.publisher.Mono;

import static org.chaiyi.template.core.common.contract.Contractor.Error.CREATE_ONE_METHOD_NOT_IMPLEMENTED;

public interface CreateOneContractor<D> extends Contractor {

    /**
     * 创建前同步执行
     */
    default D createBefore(String tenantId, String buCode, D entity) {
        return entity;
    }

    default Mono<D> create(String tenantId, String buCode, D entity) {
        CREATE_ONE_METHOD_NOT_IMPLEMENTED.trigger();
        return null;
    }

    /**
     * 创建后异步执行
     */
    default void  createAfter(String tenantId, String buCode, D entity) {

    }
}
